//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    houBaoStyle:1,
    userInfo:[],
    kongling:'',
    Money:'',
    Number:'',
    showModal:true,
    pick:true,
    system:[],
    selectTime:30,
    gezi: ["9宫格", "16宫格", "25宫格", "36宫格"],
    gongge:"9宫格",
    addPic:"../image/upLoadPic.png",
    
  },
  //事件处理函数
  ChangeTab:function(e){
    var that = this;
    console.log("currentTab")
    var currentTab = e.currentTarget.dataset.id;
    that.setData({
      houBaoStyle: currentTab,
    })
  },
  daojishi: function (time) {
    var that = this;
    console.log(time)
    count_down(time);
    function count_down(time) {
      console.log(time)
      time--;
      if (time<= 0) {
        // 截至的处理程序：
        // timeout则跳出递归
        return;
      }
      setTimeout(function () {
        // 放在最后--
        count_down(time);
      }, 1000)
    }

  },
  onLoad: function () {
    var that = this;
    // that.daojishi(15);


    wx.getUserInfo({
      success:function(user){
        console.log(user)
        that.setData({
          userInfo:user.userInfo,
        })
      }
    })
    wx.getSystemInfo({
      success: function(res) {
        console.log(res);
        that.setData({
          system:res,
        })
      },
    })
  },
  // 获取图片
  chooseImage:function(){
    var that = this;
    wx.chooseImage({
      count:1,
      success: function(res) {
        console.log(res);
        that.setData({
          addPic:res.tempFilePaths,
        })
      },
    })
  },

  // 跳转链接

  tomyRecord:function(){
    var that = this;
    wx.navigateTo({
      url: './mRecord/myRecord',
    })

  },
  // 获取页面填入的值
  koulingInput:function(e){
    var that = this;
    console.log(e.detail.value)
    that.setData({
      kouling:e.target.value,
    })
  },
  MoneyInput:function(e){
    var that = this;
    console.log(e.detail.value)
    that.setData({
      Money: e.target.value,
    })
  },
  NumberInput: function (e) {
    var that = this;
    console.log(e.detail.value)
    that.setData({
      Number: e.target.value,
    })
  },
  selectTime:function(res){
    var that = this;
    console.log(res.currentTarget.dataset.selecttime);
    that.setData({
      selectTime:res.currentTarget.dataset.selecttime
    })
  },
  showModal:function(){
    var that = this;
    that.setData({
      showModal:true,
      pick:true,
    })
  },
  timeSelect:function(e){
    var that = this;
    that.setData({
      selectTime:e.detail.value,
    })
  },
  confirmTime:function(){
    var that = this;
    that.setData({
      showModal: true,
    })
  },
  setTime:function(){
    var that = this;
    that.setData({
      showModal:false,
    })
  },
  clearTime:function(){
    var that = this;
    that.setData({
      selectTime:'',
    })
  },
  setpick:function(){
    var that = this;
    that.setData({
      pick:false,
    })
  },
  bindChange: function (e) {
    const val = e.detail.value;
    console.log(this.data.gezi[val]);
    this.setData({
      gongge:this.data.gezi[val],
    })
  }

})
